package com.ykdl.member.views;

import java.util.List;

import com.ykdl.member.kid.R;
import com.ykdl.member.kid.adapters.ViewFlowAdapter;
import com.ykdl.member.kid.gears.HomeActivity;
import com.ykdl.member.kid.models.AdItemBean;
import com.ykdl.member.kid.widget.CircleFlowIndicator;
import com.ykdl.member.kid.widget.ViewFlow;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.RelativeLayout;

/***
 * 辣妈育儿首页
 * 资讯图片轮播视图
 * @author yuanwenfei
 *
 */
public class HomeImageCarousel extends RelativeLayout {
	private Context context = null;
	private ViewFlow viewFlow = null;
	private List<AdItemBean>  adItems = null;
	public HomeImageCarousel(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}
	public HomeImageCarousel(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public HomeImageCarousel(Context context) {
		super(context);
	}
	public void setData(List<AdItemBean> list){
		this.adItems = list;
	}
	
	public void initView(Context context, HScrollView sv){
		this.context = context;
		LayoutInflater.from(context).inflate(R.layout.home_image_carousel_view, this, true);
		
		viewFlow = (ViewFlow)findViewById(R.id.viewflow);// 获得viewFlow对象
		viewFlow.setAdapter(new ViewFlowAdapter(context, this.adItems)); // 对viewFlow添加图片
		viewFlow.setmSideBuffer(this.adItems.size());
		CircleFlowIndicator indic = (CircleFlowIndicator)findViewById(R.id.viewflowindic); // viewFlow下的indic
		
		viewFlow.setFlowIndicator(indic);
		viewFlow.setTimeSpan(5500);
		viewFlow.setSelection(3); // 设置初始位置
		viewFlow.startAutoFlowTimer(); // 启动自动播放
//		sv.setView(viewFlow);
	}

}
